Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / extras / the jucer / src / model / components / jucer_ComponentUndoableAction.h
blob238d8bf5cab86c0f7a2186f5a3501fc9013abf9f
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCER_COMPONENTUNDOABLEACTION_JUCEHEADER__
27 #define __JUCER_COMPONENTUNDOABLEACTION_JUCEHEADER__
29 #include "../../ui/jucer_JucerDocumentHolder.h"
32 //==============================================================================
33 /**
35 template <class ComponentType>
36 class ComponentUndoableAction : public UndoableAction
38 public:
39 ComponentUndoableAction (ComponentType* const comp,
40 ComponentLayout& layout_)
41 : layout (layout_),
42 componentIndex (layout_.indexOfComponent (comp))
44 jassert (comp != 0);
45 jassert (componentIndex >= 0);
48 ~ComponentUndoableAction()
52 ComponentType* getComponent() const
54 ComponentType* const c = dynamic_cast <ComponentType*> (layout.getComponent (componentIndex));
55 jassert (c != 0);
56 return c;
59 int getSizeInUnits() { return 2; }
61 protected:
62 ComponentLayout& layout;
63 const int componentIndex;
65 void changed() const
67 jassert (layout.getDocument() != 0);
68 layout.getDocument()->changed();
71 void showCorrectTab() const
73 JucerDocumentHolder* const docHolder = JucerDocumentHolder::getActiveDocumentHolder();
75 if (docHolder != 0)
76 docHolder->showLayout();
78 if (layout.getSelectedSet().getNumSelected() == 0)
80 ComponentType* const c = dynamic_cast <ComponentType*> (layout.getComponent (componentIndex));
82 if (c != 0)
83 layout.getSelectedSet().selectOnly (getComponent());
87 private:
88 ComponentUndoableAction (const ComponentUndoableAction&);
89 ComponentUndoableAction& operator= (const ComponentUndoableAction&);
94 #endif // __JUCER_COMPONENTUNDOABLEACTION_JUCEHEADER__